home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / maximus / mul100.zip / PACK.SCR < prev    next >
Text File  |  1993-02-01  |  6KB  |  147 lines

  1.  
  2. // PACK.SCR  --  Maximus User Base Packer  --  Version 1.00
  3. //
  4. // Script program for MUL - the Maximus User Language
  5. // MUL is (C) Copyright 1990-93 by CodeLand Australia
  6.  
  7. // PACK scans your user base, marking records deleted that have not
  8. // called within the days since last call values set below, and then
  9. // packs the user base to remove the deleted records. Fairly simple,
  10. // this script is easily modified to include other deletion criteria,
  11. // such as key possession, credit value, etc.
  12.  
  13. // PACK optionally logs deleted records to a Binkley style log file, see
  14. // the 'syslog' variable setting below.
  15.  
  16. char *ufile = "USER.BBS";                   // Path & name of Maximus user file
  17. //char *ufile = "C:\\BBS\\USER.BBS";        // Path & name of Maximus user file
  18.  
  19. //char *syslog = "";                        // No log file
  20. char *syslog = "PACK.LOG";                  // Log file name
  21.  
  22. // Delete criteria, edit to suit your preference
  23. int HiddenDys =     30;                     // Delete days since last call
  24. int TwitDys =       30;                     // Delete days since last call
  25. int DisgraceDys =   30;                     // Delete days since last call
  26. int LimitedDys =    60;                     // Delete days since last call
  27. int NormalDys =    180;                     // Delete days since last call
  28. int WorthyDys =    210;                     // Delete days since last call
  29. int PrivilDys =    240;                     // Delete days since last call
  30. int FavoredDys =   270;                     // Delete days since last call
  31. int ExtraDys =     360;                     // Delete days since last call
  32. int ClerkDys =     360;                     // Delete days since last call
  33. int AsstsysopDys = 360;                     // Delete days since last call
  34. int SysopDys =     360;                     // Delete days since last call
  35.  
  36. char *banner = "PACK v1.00";                // Script banner
  37. char *desc = "Maximus User Base Packer";    // Description
  38.  
  39. int backch=0xB0;                            // Background fill character
  40. int bdr = 0;                                // Window border type
  41. int battr = Attr (WHITE,RED);               // Colour - window border
  42. int qattr = Attr (LRED,RED);                // Colour - windows headings
  43. int wattr = Attr (BLACK,RED);               // Colour - window body
  44. int fattr = Attr (YELLOW,BLACK);            // Colour - window fields
  45.  
  46. int deleted=0;                              // Records deleted count
  47. char buf[128];                              // Work buffer
  48.  
  49. main ()                                     // Main program
  50. {
  51.     int rec=2;
  52.  
  53.     if (!BaseOpen (ufile)) {
  54.         printf ("\nERROR opening user file \"%s\"\n\n",ufile);
  55.         exit ();
  56.     }
  57.  
  58.     background ();                          // Display background
  59.  
  60.     if (Wopen (15,8,22,70,bdr,battr,battr)) {
  61.         Wshadow (Attr (LGREY,BLACK));
  62.         Wxyprintf (0,12,qattr,"%s - %s",banner,desc);
  63.         Wxyputs (2, 3,wattr,"Action:");
  64.         Wxyputs (2,26,wattr,"Record:"); Wxyputs (2,34,fattr,"   1");
  65.         Wxyputs (2,42,wattr,"Deleted:"); Wxyputs (2,51,fattr,"   0");
  66.         Wxyputs (4,3,wattr,"Name:");
  67.         Wxyputs (4,11,fattr,"                                   ");
  68.  
  69.         // Log the start
  70.         sprintf (buf,"Pack begin, found %u records",BaseCount ());
  71.         SysLog (syslog,buf);
  72.  
  73.         // Delete scan
  74.         Wxyputs (2,11,fattr,"Delete Scan");
  75.         while (BaseRead (rec)) {
  76.             if (!(rec%20)) Wxyprintf (2,34,fattr,"%4d",rec);
  77.             delete_check (rec);
  78.             ++rec;
  79.         }
  80.  
  81.         if (deleted) {
  82.             Wxyputs (2,34,fattr,"    ");
  83.             Wxyputs (2,11,fattr,"Base Pack  ");
  84.             BasePack (ufile);
  85.         }
  86.  
  87.         // Log ending
  88.         sprintf (buf,"Pack end, %u records deleted",deleted);
  89.         SysLog (syslog,buf);
  90.  
  91.         Wclose ();
  92.     }
  93.  
  94.     Wclose (); Wclose ();                   // Close windows
  95.     BaseClose ();                           // Close the user base
  96. }
  97.  
  98. background ()                               // Display background
  99. {
  100.     Wfillch (backch);
  101.     Wopen (0,0,NumRows ()-1,NumCols ()-1,5,0,Attr (RED,LGREY));
  102.     Wfillch (0x20);
  103.     Hidecur ();                             // Hide the cursor
  104.  
  105.     About (-2);                             // MUL title window
  106. }
  107.  
  108. // This function may be modified to include other deletion criteria
  109. delete_check (int rec)                      // Check record for deletion
  110. {
  111.     int c=BaseDaysLCall ();
  112.  
  113.     if (USRflagdel) return;                 // If already deleted
  114.     if (USRflagperm) return;                // If a permanent record
  115.     
  116.     // Check days since last call for priviledge level
  117.     if      (USRpriv==HIDDEN   ) { if (c>HiddenDys   ) delete_record (rec,c); }
  118.     else if (USRpriv==TWIT     ) { if (c>TwitDys     ) delete_record (rec,c); }
  119.     else if (USRpriv==DISGRACE ) { if (c>DisgraceDys ) delete_record (rec,c); }
  120.     else if (USRpriv==LIMITED  ) { if (c>LimitedDys  ) delete_record (rec,c); }
  121.     else if (USRpriv==NORMAL   ) { if (c>NormalDys   ) delete_record (rec,c); }
  122.     else if (USRpriv==WORTHY   ) { if (c>WorthyDys   ) delete_record (rec,c); }
  123.     else if (USRpriv==PRIVIL   ) { if (c>PrivilDys   ) delete_record (rec,c); }
  124.     else if (USRpriv==FAVORED  ) { if (c>FavoredDys  ) delete_record (rec,c); }
  125.     else if (USRpriv==EXTRA    ) { if (c>ExtraDys    ) delete_record (rec,c); }
  126.     else if (USRpriv==CLERK    ) { if (c>ClerkDys    ) delete_record (rec,c); }
  127.     else if (USRpriv==ASSTSYSOP) { if (c>AsstsysopDys) delete_record (rec,c); }
  128.     else if (USRpriv==SYSOP    ) { if (c>SysopDys    ) delete_record (rec,c); }
  129. }
  130.  
  131. delete_record (int rec, int days)           // Delete the record
  132. {
  133.     USRflagdel=1;                           // Set delete flag
  134.     BaseWrite (rec);                        // Update the user file
  135.     ++deleted;                              // Count the deletion
  136.     Wxyprintf (2,51,fattr,"%4d",deleted);   // Report count
  137.     Wxyprintf (4,11,fattr,"%-35s",USRname); // Report deleted name
  138.  
  139.     // Log the deletion
  140.     sprintf (buf,"Pack Deleting %-20s (%s %3u days)",
  141.         USRname,BasePrivStr (USRpriv),days);
  142.     SysLog (syslog,buf);
  143. }
  144.  
  145. // End of script
  146.  
  147.